angular.module('start.user.auth.authselect.ctrl', [])

  .controller('authselectCtrl', function($scope, $$UserAuthService, $rootScope, $location, $ionicLoading) {
    console.log("authselectCtrl");

    // 0未认证 1 实名认证中 2 身份识别中 3 已认证 4 认证失败
    $scope.realNameAuthenticationState = null;

    // 0 未认证 1 认证中 2 已认证 3 认证失败
    $scope.guideAuthenticationState = null;

    $$UserAuthService.authenticationState()
      .then(function(res) {
        $scope.realNameAuthenticationState = res.data.realNameAuthenticationState;
        $scope.guideAuthenticationState = res.data.guideAuthenticationState;
        $scope.goAuthRealname = goAuthRealname;
        $scope.goAuthGuide = goAuthGuide;
      });

    // 实名认证
    var goAuthRealname = function(argument) {
      if ($scope.realNameAuthenticationState === 0 ||
        $scope.realNameAuthenticationState === 3 ||
        $scope.realNameAuthenticationState === 4) {
        $location.path("authrealname");
      }
    };

    // 向导认证
    var goAuthGuide = function(argument) {
      if ($scope.guideAuthenticationState === 0 ||
        $scope.guideAuthenticationState === 2||
        $scope.guideAuthenticationState === 3) {
        $location.path("authguide");
      }
    };



  });
